package View;

import javax.imageio.ImageIO;
import javax.swing.JPanel;

import java.awt.Graphics;
import java.awt.GridBagLayout;
import javax.swing.JButton;
import java.awt.GridBagConstraints;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.image.BufferedImage;
import java.awt.Insets;
import java.io.File;
import java.io.IOException;

public class NewAndLoadPageView extends JPanel{
	public NewAndLoadPageView() {
		final GridBagLayout gridBagLayout = new GridBagLayout();
		gridBagLayout.columnWidths = new int[]{0, 0, 0, 0, 0};
		gridBagLayout.rowHeights = new int[]{0, 0, 0, 0, 0, 0, 0, 0};
		gridBagLayout.columnWeights = new double[]{0.0, 0.0, 0.0, 0.0, Double.MIN_VALUE};
		gridBagLayout.rowWeights = new double[]{0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 
		        Double.MIN_VALUE};
		setLayout(gridBagLayout);
		
		final JButton btnNewButton = new JButton("New Game");
		btnNewButton.addActionListener(new ActionListener() {
			@Override
			public void actionPerformed(ActionEvent arg0){
			    System.out.println("Blank");
			}
		});
		final GridBagConstraints gbc_btnNewButton = new GridBagConstraints();
		gbc_btnNewButton.insets = new Insets(0, 0, 0, 5);
		gbc_btnNewButton.gridx = 1;
		gbc_btnNewButton.gridy = 6;
		add(btnNewButton, gbc_btnNewButton);
		
		final JButton btnLoadGame = new JButton("Load Game");
		final GridBagConstraints gbc_btnLoadGame = new GridBagConstraints();
		gbc_btnLoadGame.gridx = 3;
		gbc_btnLoadGame.gridy = 6;
		add(btnLoadGame, gbc_btnLoadGame);
	}

	public void paintComponent (Graphics g){
		super.paintComponent(g);
		BufferedImage image = null;
		try{
			image = ImageIO.read(new File("src\\View\\title page.jpg"));
			
		}
		catch(IOException e){
			System.out.println(e.getMessage());
			}
		
		g.drawImage(image, 0, 0, null);
		
	}



}
